USE GESTION2
go

IF OBJECT_ID('dbo.WASP_D0004_CREA_TABLA_BLOQUEO_EMPRESA') IS NOT NULL 
   BEGIN
      DROP PROCEDURE dbo.WASP_D0004_CREA_TABLA_BLOQUEO_EMPRESA 
      IF OBJECT_ID('dbo.WASP_D0004_CREA_TABLA_BLOQUEO_EMPRESA') 
      IS
      NOT NULL 
         PRINT 
         '<<< FAILED DROPPING PROCEDURE dbo.WASP_D0004_CREA_TABLA_BLOQUEO_EMPRESA >>>'
      ELSE
         PRINT 
         '<<< DROPPED PROCEDURE dbo.WASP_D0004_CREA_TABLA_BLOQUEO_EMPRESA >>>' 
   END
go

SET ANSI_NULLS ON
go

SET QUOTED_IDENTIFIER ON
go

CREATE PROCEDURE [dbo].[WASP_D0004_CREA_TABLA_BLOQUEO_EMPRESA] 
AS
   SELECT z07325cta AS CLAVEEMPRESA,
      Z07325TOT AS NroTrabajadores,
      Z07325BLO AS Bloqueo,
      Z07325UPE AS FechaCoti,
      Z07303DSC 
   INTO dbo.bloqueo_empresa 
   FROM z07325 AS a(nolock) LEFT JOIN z07303 AS b (nolock) ON a.Z07303COD = b.Z07303COD
--z07325 as a(nolock) , z07303 as b (nolock) 
--where a.Z07303COD *= b.Z07303COD

go



SET ANSI_NULLS OFF
go

SET QUOTED_IDENTIFIER OFF
go

IF OBJECT_ID('dbo.WASP_D0004_CREA_TABLA_BLOQUEO_EMPRESA') IS NOT NULL 
   PRINT '<<< CREATED PROCEDURE dbo.WASP_D0004_CREA_TABLA_BLOQUEO_EMPRESA >>>' 
ELSE
   PRINT 
   '<<< FAILED CREATING PROCEDURE dbo.WASP_D0004_CREA_TABLA_BLOQUEO_EMPRESA >>>'
go
